package com.corpdata.system.org.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.corpdata.common.base.BaseController;
import com.corpdata.common.result.DataGrid;
import com.corpdata.common.result.Result;
import com.corpdata.system.org.entity.User;
import com.corpdata.system.org.service.UserService;

@Controller
@RequestMapping("/system/org/user")
public class UserController extends BaseController{
	
	@Autowired
	private UserService userService;
	
	@GetMapping(value = "/list")
	public String list(Model model, HttpServletRequest request) {
		return "system/org/user/user_list";
	}
	
	@RequestMapping("/listdata")
	@ResponseBody
	public DataGrid<User> getList(DataGrid dt){
		if (null == dt) {
            return null;
        }
		return userService.selectByPage(dt);
	}
	
	@RequestMapping("/listdata2")
	@ResponseBody
	public DataGrid<User> getList2(String param1,int param2){
		DataGrid dt = new DataGrid<>();
		dt.setPage(1);
		dt.setSize(15);
		return userService.selectByPage(dt);
	}
	
	
	@ResponseBody
	@PostMapping("create")
	public Result create(){
		return userService.create(null);
	}
	
	@ResponseBody
	@PostMapping("delete")
	public Result delete(){
		return userService.delete("1");
	}
}
